<!DOCTYPE html>
<html>
<head>
    <title>商品管理</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <#include "../../../../include/resources.html">

        <script type="text/javascript">
            var dataGrid;
            var winWidth =  900; //弹出窗口宽度
            var winHeight = 500; //弹出窗口高度
            var editTitle = "编辑商品";
            var editUrl =  "/modules/additional/commodity/commodityEditPage.html";
            var detailTitle = "商品详情";
            var detailUrl = "/modules/additional/commodity/commodityDetailPage.html";
            var addTitle = "添加商品";
            var addUrl = "/modules/additional/commodity/commodityAddPage.html";
            var deleteTitle ="删除商品";
            var deleteUrl = "/modules/additional/commodity/doCommodityDelete.html";
            var disableTitle = "禁用商品";
            var disableUrl = "/modules/additional/commodity/commodityDisable.html";
            var enableTitle = "启用商品";
            var enableUrl = "/modules/additional/commodity/commodityEnable.html";
            var deltxt = "删除";
            var delval = 1;
            var txt1 = "禁用";
            var txt2 = "启用";
            var val1 = 1;
            var val2 = 0;

            $(function() {
                dataGrid = $('#dataGrid').datagrid({
                    url : 'commodityList.html',
                    fit : true,
                    fitColumns : true,
                    border : false,
                    pagination : true,
                    idField : 'id',
                    pageSize : pageSize,
                    pageNums :1,
                    pageList : pageList,
                    sortName : 'id',
                    sortOrder : 'asc',
                    checkOnSelect : false,
                    selectOnCheck : false,
                    nowrap : false,
                    singleSelect:true,
                    columns : [ [
                        { field: 'id', title: '编号', width: 50, checkbox : false},
                        { field: 'name', title: '名称', width: 80, checkbox : false},
                        { field: 'category', title: '类别', width: 50, sortable:false,formatter:
                            function(value,row,index){
                                if(row.category == 1)
                                    return "积分抽奖";
                                else if(row.category == 2)
                                    return "签到抽奖";
                                else if(row.category == 3)
                                    return "满审成功活动";
                            }
                        },
                        { field: 'totalNum', title: '总数量', width: 40, sortable:false},
                        { field: 'issueNum', title: '已发放量', width: 40, sortable:false},
                        { field: 'status', title: '状态', width: 40, sortable:false,formatter:function(value,row,index){
                            if(row.status == 0)
                                return "启用";
                            else if(row.status == 1)
                                return "禁用";
                        } },
                        { field: 'remark', title: '备注', width: 100, sortable:false },
                        { field: 'modifierName', title: '修改者', width: 60, sortable:false },
                        { field: 'modifyTime', title: '修改时间', width: 80, sortable:false,formatter: function(value,row,index){
                            return getLocalTime(value,4);
                        }
                        },
                        { field: 'creatorName', title: '创建者', width: 60, sortable:false },
                        { field: 'createTime', title: '创建时间', width: 80, sortable:false,formatter: function(value,row,index){
                            return getLocalTime(value,4);
                        }
                        },
                        { field : 'showInfo',
                            title : '其他信息',
                            width :75,
                            fixed : true,
                            align : 'center',
                            formatter : function(value, row, index) {
                                var content = '<a href="javascript:void(0);" class="j-showInfo">查看<i class="iconfont">&#xe639;</i></a>'
                                        + '<div class="showInfoSingleDiv">'
                                        + '<div class="showInfo">'
                                        + '<em></em><h2>商品信息</h2>'
                                        + '<ul>'
                                        + '<li>'
                                        + '<span>创建时间：</span>'
                                        + getLocalTime(row.createTime,4)
                                        + '</li>'
                                        + '<li>'
                                        + '<span>备注：</span>'
                                        + row.remark
                                        + '</li>'
                                        + '</ul></div></div>';
                                return content;
                            }
                        },
                        { field : 'action',
                            title : '操作',
                            width : 75,
                            fixed : true,
                            align : 'center',
                            formatter : function(value, row, index) {
                                var str = '';
                                str += '<dl>';
                                str += '<dt><a href="javascript:void(0);" onclick="$.fn.dataGridOptions.closeFun('+row.id+',detailTitle,winWidth,winHeight,detailUrl);" title="'+detailTitle+'">详情</a><i class="iconfont">&#xe639;</i></dt>' ;
                                str += '<dd>';
                                str += '<a href="javascript:void(0);" onclick="$.fn.dataGridOptions.editFun('+row.id+',editTitle,winWidth,winHeight,editUrl);" title="'+editTitle+'">编辑</a>';
                                if(row.status==0){
                                    str += '<a href="javascript:void(0);" onclick="$.fn.dataGridOptions.recordOptFun('+row.id+',disableUrl,txt1,val1);">禁用</a>';
                                } else if(row.status==1){
                                    str += '<a href="javascript:void(0);" onclick="$.fn.dataGridOptions.recordOptFun('+row.id+',enableUrl,txt2,val2);">启用</a>';
                                }
                                str += '<a href="javascript:void(0);" onclick="$.fn.dataGridOptions.recordOptFun('+row.id+',deleteUrl,deltxt,delval);">删除</a>';
                                str += '</dd>'
                                str +=  '</dl>'
                                return str;
                            }
                        }

                    ] ],
                    toolbar : '#toolbar',
                    onLoadSuccess : function() {
                        $('#searchForm table').show();
                        parent.$.messager.progress('close');
                    }
                });
            });

        </script>
</head>
<body style="padding:0 20px;" >
<div class="easyui-layout" data-options="fit : true,border : false">
    <div data-options="region:'north',border:false,collapsible:false" id="searchBox">
        <div class="sLeft">
            <form id="searchForm">
                <input type="text"  name="searchName" class="sInput" placeholder="输入名称进行搜索" autocomplete="off" onkeydown="if(event.keyCode == 13){ $.fn.dataGridOptions.searchFun('#searchForm');return false;}"/><a href="javascript:;" title="查询" class="sBtn" onclick="$.fn.dataGridOptions.searchFun('#searchForm');">查询</a>
                <a href="javascript:void(0);" class="reloadIcon" onclick="dataGrid.datagrid('reload');" title="刷新" ><i class="iconfont">&#xe603;</i></a>
            </form>
        </div>
        <form id="showAdw">
        </form>
        <div class="sRight">
            <a onclick="$.fn.dataGridOptions.addFun(-1,addTitle,winWidth,winHeight,addUrl);" href="javascript:void(0);" class="addBtn"><i class="iconfont">&#xe629;</i>添加商品规则</a>
        </div>
    </div>
    <div data-options="region:'center'" style="margin-top:30px;padding-bottom:30px;">
        <table id="dataGrid"></table>
    </div>
</div>
</body>
</html>
<script src="${theme_dir}/js/search.js"></script>